<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use App\Base\Annotation\Common;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource()
 * @ODM\Document(repositoryClass="App\Repository\SiteGunRepository")
 */
class SiteGun
{
    /**
     * @Common(cnName="#",editType="text",listType="text")
     * @ODM\Id(strategy="INCREMENT")
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @Groups({"list"})
     */
    private $id;

    /**
     * @Common(cnName="油枪号",editType="text",listType="text")
     * @ODM\Field(type="raw",  nullable=false)
     * @ORM\Column(type="string", length=255)
     * @Groups({"list"})
     */
    private $name;

    /**
     * @Common(cnName="是否可用",editType="switch",listType="text")
     * @ODM\Field(type="boolean",  nullable=false)
     * @ORM\Column(type="boolean", nullable=true)
     * @Groups({"list"})
     */
    private $isUse = true;

    /**
     * @Common(cnName="油号",editType="entity",listType="text")
     * @ODM\ReferenceOne(targetDocument="App\Entity\SiteOil", inversedBy="guns")
     * @ORM\ManyToOne(targetEntity="App\Entity\SiteOil", inversedBy="guns")
     */
    private $oil;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

    public function getIsUse(): ?bool
    {
        return $this->isUse;
    }

    public function setIsUse(?bool $isUse): self
    {
        $this->isUse = $isUse;

        return $this;
    }

    public function getOil(): ?SiteOil
    {
        return $this->oil;
    }

    public function setOil(?SiteOil $oil): self
    {
        $this->oil = $oil;

        return $this;
    }
}
